package com.sls.nzdapplication.ui.activity;

import android.content.ContentResolver;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.github.chrisbanes.photoview.PhotoView;
import com.sls.nzdapplication.R;

import java.io.File;
import java.io.InputStream;

public class PhotoDetailActivity extends AppCompatActivity {
    PhotoView photoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo_detail);
        photoView = (PhotoView) findViewById(R.id.hitcard_photodetail_view);
        photoView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               PhotoDetailActivity.this.finish();
            }
        });
        String filepath = getIntent().getStringExtra("filePath");
        File file = new File(filepath);
        Uri uri = Uri.fromFile(file);
        ContentResolver cr = getApplication().getContentResolver();
        try {
            InputStream is = cr.openInputStream(uri);
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize =3;
            Bitmap bitmap = BitmapFactory.decodeStream(is,null,options);
            photoView.setImageBitmap(bitmap);
        }
        catch(Exception e)
        {
        }

    }


}